﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Linq;

namespace testlan2.DAL
{
    class xulyDAL
    {
        DataClasses1DataContext db=new DataClasses1DataContext();
        public List<HOCPHAN> getTable()
        {
            DataClasses1DataContext db=new DataClasses1DataContext();
            List<HOCPHAN> list=db.HOCPHANs.ToList();
            return list;
        }
        public HOCPHAN getMAHOC(string mahp)
        {
            return db.HOCPHANs.Where(p=>p.MaHP==mahp).FirstOrDefault();
        }
        public void addHP(HOCPHAN p)
        {
            db.HOCPHANs.InsertOnSubmit(p);
            db.SubmitChanges();
        }
        public void xoa(HOCPHAN p)
        {
            db.HOCPHANs.DeleteOnSubmit(p);
            db.SubmitChanges();
        }
        public void update()
        {
            db.SubmitChanges();
        }
    }
}
